#!/bin/bash
#

##重命名 1.txt——>1_YYYY_MM_DD.txt

YYYY=$(date +%F | awk -F- '{print $1}')
MM=$(date +%F | awk -F- '{print $2}')
DD=$(date +%F | awk -F- '{print $3}')
for old_file in $(find /opt/test -name "*.txt"); do
    #echo $old_file
    qian=$(echo $old_file | awk -F. '{print $1}')
    new_file=${qian}_${YYYY}_${MM}_${DD}.txt
    #echo $new_file
    mv ${old_file} ${new_file}
done
